/**
 * 
 */
package com.magnusart.scrumppm.gui;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;

import com.magnusart.scrumppm.presenters.AbstractPresenter.WidgetTypes;

/**
 * Lists the details of the Project
 * @author Magnus Andersson
 *
 */
public class ProjectDetails extends Composite
{
	private final GridLayout layout;
	private final Text projectName;
	private GridData data;
	private final Text detailsArea;
	private final Button deleteProjectButton;
	private final Group detailsGroup;

	public ProjectDetails( Composite parent ) {
		super( parent, SWT.NONE );	
	}

	{
		// Setup the layout
		layout = new GridLayout();
		layout.numColumns = 2;
		layout.makeColumnsEqualWidth = false;
		//layout.verticalSpacing = 10;
		
		setLayout( layout );

		data = new GridData( GridData.BEGINNING | GridData.HORIZONTAL_ALIGN_FILL );
		data.horizontalSpan = 2;
		
		// Setup the label
		projectName = new Text( this, SWT.SINGLE );
		projectName.setText( "" );
		projectName.setEditable( false );
		projectName.setBackground( this.getBackground() );
		projectName.setFont( FontFormatter.getBoldFont() );
		projectName.setLayoutData( data );
		projectName.setData( WidgetTypes.ProjectNameSelection );
	
		data = GridDataFactory.copyData( data );
		data.grabExcessHorizontalSpace = true;
		data.grabExcessVerticalSpace = true;
		data.verticalAlignment = SWT.BEGINNING;
		
		data = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.FILL_BOTH );
		
		detailsGroup = new Group( this, SWT.NO_BACKGROUND );
		detailsGroup.setText( "Description" );
		detailsGroup.setLayoutData( data  );
		detailsGroup.setLayout( new GridLayout() );

		data = GridDataFactory.copyData( data );
		
		detailsArea = new Text( detailsGroup , SWT.MULTI | SWT.WRAP );
		detailsArea.setEditable( false );
		detailsArea.setText( "" );
		detailsArea.setBackground( this.getBackground() );
		detailsArea.setLayoutData( data );
		detailsArea.setData( WidgetTypes.DetailsAreaSelection );
		
		data = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END );
		data.horizontalSpan = 2;
		
		data = GridDataFactory.copyData( data );
		deleteProjectButton = new Button( this, SWT.PUSH );
		deleteProjectButton.setText( "Delete this project" );
		deleteProjectButton.setLayoutData( data );
		deleteProjectButton.setData( WidgetTypes.DeleteProjectButton );
	}
	
	/**
	 * @return The label that shows the project name.
	 */
	public Text getProjectName() {
		return projectName;
	}

	/**
	 * @return The area that shows the project details.
	 */
	public Text getDetailsArea() {
		return detailsArea;
	}

	/**
	 * 
	 * @return The button that is used to delete a project.
	 */
	public Button getDeleteProjectButton() {
		return deleteProjectButton;
	}
	
	
	
}
